<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <title>X-admin v1.0</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="/woniu/Public/X-admin/css/x-admin.css" media="all">
    </head>
    
    <body>
        <div class="x-body">
            <form class="layui-form" method="post">
                <input type='hidden' name='id' value="<?php echo ($list[0]['id']); ?>">
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                    小组名:
                    </label>
                    <div class="layui-input-inline">
                        <input type="text"  name="name"  lay-verify="required" autocomplete="off" value="<?php echo ($list[0]['name']); ?>" class="layui-input">
                    </div>
                    
                </div>

                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label"></label>
                    <button  class="layui-btn" lay-filter="add" lay-submit="">修改</button>
                    <button  class="layui-btn" lay-filter="del" lay-submit="">删除</button>
                </div>
            </form>
        </div>
        <script src="/woniu/Public/X-admin/lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="/woniu/Public/X-admin/js/x-layui.js" charset="utf-8">
        </script>
        <script>

            layui.use(['form','layer','laydate'], function(){
              $ = layui.jquery;
              var form = layui.form();
              var laydate = layui.laydate;
              layer = layui.layer;

              //监听提交
              form.on('submit(add)', function(data){
                
                name=$("input[name='name']").val();
                id=$("input[name='id']").val();
                // post方式修改
                $.post('/woniu/index.php/Home/Classmanage/tupdate',{name:name,id:id},function(data){
                    // alert(data);
                    if(data=="修改成功"){
                       layer.alert("修改成功", {icon: 6},function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            parent.reload();
                        });
                    }else{
                        alert('数据修改失败');
                        return false;
                    }
                });
                    return false;
              });

              // 删除
              form.on('submit(del)', function(data){
                
                id=$("input[name='id']").val();
                // post方式修改
                $.post('/woniu/index.php/Home/Classmanage/del',{id:id},function(data){
                    // alert(data);
                    if(data=="成功"){
                       layer.alert("删除成功", {icon: 6},function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            parent.reload();
                        });
                    }else{
                        alert('数据删除失败');
                    }
                });
                    return false;
              });
            }); 
        </script>
    </body>

</html>